# 使用公共方法，在main方法中调用
import requests


class WorkFlowForgetPasswordTestV2:
    def register_test(self, url, user_info, exp_result, name):

        # 发送请求
        res = requests.post(url, data=user_info).text
        print(res)
        r = res.find(exp_result)
        if r > 0:
            print(name + "测试通过")
        else:
            print(name + "测试不通过")


if __name__ == '__main__':
    work_flow_obj2 = WorkFlowForgetPasswordTestV2()
    url = "http://129.211.129.101:9006/user/register.do"
    # 正确的用户数据
    user_info = {
        "username": "lllljl",
        "password": "111111",
        "email": "lllljjj@qq.com",
        "phone": "13555555556",
        "question": "喜欢看的书",
        "answer": "阿衰"
    }
    exp_result = "注册成功"
    name = "注册接口"
    work_flow_obj2.register_test(url, user_info, exp_result, name)

    ######################登录接口测试数据及调用#############################
    url = "http://129.211.129.101:9006/user/login.do"
    # 正确的用户数据
    user_info = {
        "username": "lllljl",
        "password": "111111"
    }
    exp_result = "登录成功"
    name = "登录接口接口"
    work_flow_obj2 = WorkFlowForgetPasswordTestV2()
    work_flow_obj2.register_test(url, user_info, exp_result, name)
